package servlet.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pojo.Customer;
import service.CartManager;
import service.impl.CartManagerFactory;

public class AddToCartActionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private CartManager manager = CartManagerFactory.INSTANCE;

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String bookId = request.getParameter("bookId");
		Customer c = (Customer) request.getSession().getAttribute("customer");
		manager.addToCart(c.getId(), bookId);
		response.sendRedirect("../cart");
	}

}
